package training01;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class PukeProgram {
    private ArrayList<Puke> pukes = new ArrayList<>();
    public PukeProgram(){
        init();
        shuffle();
        send();
    }
    public void init(){
        String [] points = "3,4,5,6,7,8,9,10,J,Q,K,A,2".split(",");
        String [] types = "♠,♥,♣,♦".split(",");
        for(int i = 0;i < points.length;i++){
            for(int j = 0;j < types.length;j++){
                pukes.add(new Puke(points[i],types[j],j,i));
            }
        }
        pukes.add(new Puke("","大王",0,14));
        pukes.add(new Puke("","小王",0,13));
//        System.out.println(pukes);
    }
    public void shuffle(){
        Collections.shuffle(pukes);
        System.out.println(pukes);
    }
    public void send(){
        List player1 = pukes.subList(0,17);
        List player2 = pukes.subList(17,34);
        List player3 = pukes.subList(34,51);
        List base = pukes.subList(51,54);


        player1.sort(new PukeComparator());
        player2.sort(new PukeComparator());
        player3.sort(new PukeComparator());
        base.sort(new PukeComparator());

        System.out.println("玩家一：" + player1);
        System.out.println("玩家二：" + player2);
        System.out.println("玩家三：" + player3);
        System.out.println("底牌：" + base);
    }
    public static void main(String[] args) {
        new PukeProgram();
    }
}
